<template>
	<view class="my_page">
		<view class="user_box">
			<image :src="user_info.avatar"></image>
			<view class="among">
				<view class="user_name">{{user_info.nickname}}</view>
				<view class="phone">{{user_info.mobile}}</view>
			</view>
			<!-- <u-icon style="margin-left: 238rpx;" name="arrow-right" size="20"></u-icon> -->
		</view>
		<view class="item_box">
			<view class="item" @click="toJump(5)">
				<image src="../../static/wallet/mm.png"></image>
				<view class="title">我的钱包</view>
				<u-icon name="arrow-right" size="20"></u-icon>
			</view>
			<view class="item" @click="toJump(4)">
				<image src="../../static/wallet/quan.png"></image>
				<view class="title">我的优惠券</view>
				<u-icon name="arrow-right" size="20"></u-icon>
			</view>
			<view class="item" @click="123">
				<image src="../../static/wallet/tongzhi.png"></image>
				<view class="title">订单通知</view>
				<u-icon name="arrow-right" size="20"></u-icon>
			</view>
			<view class="item" @click="toJump(3)">
				<image src="../../static/wallet/bangding.png"></image>
				<view class="title">账户绑定</view>
				<u-icon name="arrow-right" size="20"></u-icon>
			</view>
		</view>
		<view class="item_box">
			<view class="item" @click="toJump(1)">
				<image src="../../static/wallet/shezhi.png"></image>
				<view class="title">设置</view>
				<u-icon name="arrow-right" size="20"></u-icon>
			</view>
			<view class="item" @click="openKeFu()">
				<image src="../../static/wallet/kefu.png"></image>
				<view class="title">联系客服</view>
				<u-icon name="arrow-right" size="20"></u-icon>
			</view>
			<view class="item" @click="toJump(2)">
				<image src="../../static/wallet/guanyu.png"></image>
				<view class="title">关于</view>
				<u-icon name="arrow-right" size="20"></u-icon>
			</view>
			<view class="item">
				<image src="../../static/wallet/jiedan.png"></image>
				<view class="title">我要接单<span style="color: #999999;font-size: 24rpx;">(下载小安到家app师傅版)</span></view>
				<u-icon name="arrow-right" size="20"></u-icon>
			</view>
		</view>
		<button class="btn" @click="logOut()">退出登录</button>
		<u-popup :show="show" mode="center" :round="12" closeOnClickOverlay @close="show=false">
			<view class="pop_box">
				<view style="font-weight: bold;">客服电话:{{kefu_phone}}</view>
				<view style="margin-top: 28rpx;font-size: 24rpx;color: #666666;">客服值班时间:{{kefu_time}}</view>
				<view class="c_btn" @click="callKeFu()">联系客服</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {userInfo,keFu} from "../../api/index.js"
	export default {
		data() {
			return {
				show:false,
				user_info:[],
				kefu_phone:'',
				kefu_time:''
			}
		},
		onShow() {
			this.getInfo()
		},
		methods: {
			getInfo(){
				userInfo().then(res=>{
					this.user_info=res.data
					uni.setStorageSync('mobile',res.data.mobile)
					console.log(res);
				})
			},
			toJump(e) {
				switch (e) {
					case 1: {
						uni.navigateTo({
							url: "/pages/my/setting"
						})
						break;
					}
					case 2: {
						uni.navigateTo({
							url: "/pages/my/about"
						})
						break;
					}
					case 3: {
						uni.navigateTo({
							url: "/pages/my/myaccount"
						})
						break;
					}
					case 4: {
						uni.navigateTo({
							url: "/pages/wallet/coupon"
						})
						break;
					}
					case 5: {
						uni.switchTab({
							url:"/pages/wallet/wallet"
						})
						break;
					}
				}
			},
			logOut(){
				uni.clearStorageSync()
				 uni.navigateTo({
				 	url:"/pages/login/login"
				 })
			},
			openKeFu(){
				this.show=true
				keFu().then(res=>{
					this.kefu_phone=res.data.phone
					this.kefu_time=res.data.wokrtime
				})
			},
			callKeFu(){
				this.show=false
				uni.makePhoneCall({
					phoneNumber:this.kefu_phone,
					success:res=> {
						console.log(res);
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.my_page {
		width: 100%;
		height: 100vh;
		background-color: #F9F9F9;
		padding: 38rpx 32rpx;

		.user_box {
			width: 100%;
			height: 100rpx;
			display: flex;

			image {
				width: 100rpx;
				height: 100rpx;
				border-radius: 100%;
			}

			.among {
				width: 300rpx;
				height: 100rpx;
				margin-left: 32rpx;

				.user_name {
					color: #333333;
					font-size: 32rpx;
					font-weight: bold;
					margin-top: 8rpx;
				}

				.phone {
					color: #666666;
					font-size: 28rpx;
					margin-top: 8rpx;
				}
			}
		}

		.item_box {
			width: 100%;
			height: 448rpx;
			background-color: #FFFFFF;
			border-radius: 8rpx;
			margin-top: 48rpx;

			.item {
				width: 100%;
				height: 112rpx;
				padding: 36rpx 32rpx;
				display: flex;
				justify-content: space-between;

				image {
					width: 40rpx;
					height: 40rpx;
				}

				.title {
					width: 80%;
					height: 100%;
					color: #333333;
					font-size: 28rpx;
					margin-left: 32rpx;
				}
			}
		}

		.btn {
			background-color: #FFFFFF;
			margin-top: 148rpx;
		}
	}
    .pop_box{
		width: 558rpx;
		height: 248rpx;
		background-color: #FFFFFF;
		border-radius: 12rpx;
		padding: 32rpx;
		text-align: center;
		.c_btn{
			width: 100%;
			height: 52rpx;
			color: #00CC7B;
			margin-top: 48rpx;
		}
	}
</style>